<%@ page language="java" contentType="text/html;charset=UTF-8"
    pageEncoding="UTF-8"%>
	<%
	String mediaCode = request.getParameter("playUrl");
	int left = Integer.parseInt(request.getParameter("left"));
	int top = Integer.parseInt(request.getParameter("top"));
	int width = Integer.parseInt(request.getParameter("width"));
	int height = Integer.parseInt(request.getParameter("height"));
	String focusFrame=request.getParameter("focusFrame");//是否显示机顶盒默认选框 0 显示 1不显示
%>
<html>
<head >
<script type="text/javascript">
(function(){
	try{
		if(<%=focusFrame%>==1){//去边框
			var STB = navigator.appName;
			if (STB == "ztebw" || STB == "Fhbw2.0") {//中兴 烽火
				iPanel.focusWidth = "0";
			} else if (STB == "JETU") {
				iPanel.focusWidth = "3";
			} else {
				iPanel.focusWidth = "-1";
			}
		}
	}catch(e){
		//console.info(e);
	}
})();
</script>
<script type="text/javascript">
	var mp = new MediaPlayer();
	var playUrl = "<%=mediaCode%>";
	
	
	
	var jsonStr = '[{mediaUrl:"'+playUrl+'",';
	jsonStr += 'mediaCode: "json1",';
	jsonStr += 'mediaType:2,';
	jsonStr += 'audioType:1,';
	jsonStr += 'videoType:1,';
	jsonStr += 'streamType:1,';
	jsonStr += 'drmType:1,';
	jsonStr += 'fingerPrint:0,';
	jsonStr += 'copyProtection:1,';
	jsonStr += 'allowTrickmode:1,';
	jsonStr += 'startTime:0,';
	jsonStr += 'endTime:20000,';
	jsonStr += 'entryID:"jsonentry1"}]';
	
	
	/*此处设置视频框的位置*/
	
	
	var playStat = "";
	var speed = 0;
	//直播播放初始化函数
	function initCHANMediaPlay() {
		var height = <%=height%>;
		var width = <%=width%>;
		var left = <%=left%>;
		var top = <%=top%>;
		var instanceId = mp.getNativePlayerInstanceID();
		var playListFlag = 0;
		var videoDisplayMode = 0;
		var muteFlag = 0;
		var useNativeUIFlag = 1;
		var subtitleFlag = 0;
		var videoAlpha = 0;
		var cycleFlag = 0;
		var randomFlag = 0;
		var autoDelFlag = 0;
		mp.setAllowTrickmodeFlag(0);
		mp.setNativeUIFlag(0);
		mp.setMuteUIFlag(0);
		mp.initMediaPlayer(instanceId, playListFlag, videoDisplayMode,height,width,left,top, 
				muteFlag, useNativeUIFlag, subtitleFlag, videoAlpha, cycleFlag, randomFlag, autoDelFlag);
		joinChannel(playUrl);
		mp.setVideoDisplayMode(0);
		mp.setVideoDisplayArea(left,top,width,height);
		mp.refreshVideoDisplay();
	}
	function initVIDEOMediaPlay(){
		var height = <%=height%>;
		var width = <%=width%>;
		var left = <%=left%>;
		var top = <%=top%>;
		var instanceId = mp.getNativePlayerInstanceID();
		var playListFlag = 0;
		var videoDisplayMode = 0;
		var muteFlag = 0;
		var useNativeUIFlag = 0;
		var subtitleFlag = 0;
		var videoAlpha = 0;
		var cycleFlag = 1;
		var randomFlag = 0;
		var autoDelFlag = 0;
		
		//初始话mediaplayer对象
		   mp.initMediaPlayer(instanceId, playListFlag, videoDisplayMode, height,width,left,top,  
		muteFlag, useNativeUIFlag, subtitleFlag, videoAlpha, cycleFlag, randomFlag, autoDelFlag);
		mp.setSingleMedia(jsonStr); 
		document.getElementById("ss").innerHTML="height=" +height+"||width="+width+"||left="+left+"||top="+top;
		    mp.setAllowTrickmodeFlag(0); //设置是否允许trick操作。 0:允许 1：不允许  
		    mp.setNativeUIFlag(0); //播放器是否显示缺省的Native UI，  0:允许 1：不允许
		mp.setAudioTrackUIFlag(1);//设置音轨的本地UI显示标志 0:不允许 1：允许      
		    mp.setMuteUIFlag(1); //设置静音的本地UI显示标志 0:不允许 1：允许
		    mp.setAudioVolumeUIFlag(1);//设置音量调节本地UI的显示标志 0:不允许 1：允许
		mp.refreshVideoDisplay();
	}
	//播放
	function play() {
		if (playUrl.indexOf("igmp")>=0){
			initVIDEOMediaPlay();
			mp.playFromStart();
		}else{
			initCHANMediaPlay();
		}
	}
	/**
	 *如果是频道，则需要加入直播
	 */
	function joinChannel(index) {
		mp.leaveChannel();
		mp.joinChannel(index);
	}
	/**
	 *停止播放
	 */
	function destoryMP() {
		mp.leaveChannel();
		mp.stop();
	}
	
	function goUtility() {
		//eval("eventJson = " + Utility.getEvent());
		Josncheck("eventJson = " + Utility.getEvent());
		var typeStr = eventJson.type;
		switch(typeStr) {
			case "EVENT_MEDIA_END":
				play();
				return false;
			case "EVENT_MEDIA_ERROR":
				mediaError(eventJson);
				return false;
			default :
				break;
		}
		return true;
	}
	function Josncheck(text) {
		var toJSON = window.eval;
		var returnValue;
		if(/((alert|on\w+|function\s+\w+)\s*\(\s*(['+\d\w](,?\s*['+\d\w]*)*)*\s*\))/.test(text)){
			console.log("xss攻击");
		}else if(/(<(script|iframe|embed|frame|frameset|object|img|applet|body|html|style|layer|link|ilayer|meta|bgsound))/.test(text)){
			console.log("xss攻击");
		}else {
			try{
				returnValue = toJSON("("+text+")");
			}catch (e) {
				console.log("json解析失败");
				try{
					returnValue = toJSON(text);
				}catch (e) {
					console.log("json解析失败2");
				}
			}
			return returnValue;

		}

	}
	
	function mediaError(eventJson) {
		var code = eventJson.error_code;
		var type = eventJson.error_message;
	}
	 
	function volUp(){
		var vol = mp.getVolume();
	    vol = (vol <= 90 ? vol+10 : 100);
	    mp.setVolume(vol);
	}
	function volDown(){
		 var vol = mp.getVolume();
	     vol = (vol >= 10 ? vol-10 : 0);
	     mp.setVolume(vol);
	}
	var plflag=0;
	function swtichjy(){//静音
		   if(plflag == 0 ){ 
			 plflag=1;
		     mp.setMuteFlag(1);
		   }else{
		     plflag=0;
		     mp.setMuteFlag(0);
		   }
	}
	function checkMvKey(keycode) {
		switch(keycode){
			case 768: //播放事件
				goUtility();
				break;
			case 259:
				volUp();
				break;
			case 260:
				volDown();
				break;
			case 261://静音
				swtichjy();
		}
	}
</script>
</head>
<body onunload="javascript:destoryMP();" onload="javascript:play();" style="margin:0;background-color:transparent;">
 <!-- <div id="ss" style="position:absolute;left:800px;top:100px; color:red;font-size: 50px;width:900px;word-wrap: break-word;">加载中...</div>
<a href="#" onclick="location.reload()">ssfsdfe</a> -->
</body>
</html>